let timeout = null;
const debounce = (func, wait = 200) => {
    if (timeout !== null) clearTimeout(timeout);
    timeout = setTimeout(() => {
        timeout = null;
        // eslint-disable-next-line no-unused-expressions
        func && func();
    }, wait);
};


const getDay = (Year, Month) => {
    let DayCount;
    if (Year < 1912 || Month < 1) { return null; }
    switch (Month) {
    case '1':
    case '3':
    case '5':
    case '7':
    case '8':
    case '10':
    case '12':
        DayCount = 31;
        break;
    case '2':
        DayCount = 28;
        if (Year % 4 === 0) { DayCount = 29; }
        break;
    default:
        DayCount = 30;
        break;
    }
    const monthDay = [];
    for (let i = 1; i <= DayCount; i += 1) {
        const Day = i < 10 ? `0${i}` : i;
        monthDay.push(`${Month}-${Day}`);
    }
    return monthDay;
};

export { debounce, getDay };
